﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using ESRI.ArcGIS.Display;
using ESRI.ArcGIS.esriSystem;
using ESRI.ArcGIS.SystemUI;
using ESRI.ArcGIS.Controls;

namespace Homework5
{
    public partial class Form5 : Form
    {
        public IStyleGalleryItem m_styleGalleryItem = null;
        string stylesPath;
        public Form5()
        {
            InitializeComponent();
        }

        private void Form5_Load(object sender, EventArgs e)
        {
            //Get the ArcGIS install location
            string sInstall = ESRI.ArcGIS.RuntimeManager.ActiveRuntime.Path;
            string defaultStyle = System.IO.Path.Combine(sInstall, "Styles\\ESRI.ServerStyle");
            if (System.IO.File.Exists(defaultStyle))
            {   //Load the ESRI.ServerStyle file into the SymbologyControl
                cbxStyles.Text = defaultStyle;
            }
            stylesPath = sInstall + "\\Styles";
            cbxStyles.Items.Clear();
            cbxStylesAddItems(stylesPath);
            axSymbologyControl1.StyleClass = esriSymbologyStyleClass.esriStyleClassColorRamps;
            axSymbologyControl1.Update();
            axSymbologyControl1.Refresh();
        }

        private void cbxStylesAddItems(string stylePath)
        {
            cbxStyles.Items.Add(stylePath);
        }

        private void axSymbologyControl1_OnItemSelected(object sender, ISymbologyControlEvents_OnItemSelectedEvent e)
        {
            //Get the selected item
            m_styleGalleryItem = (IStyleGalleryItem)e.styleGalleryItem;
        }

        private void button1_Click(object sender, EventArgs e)
        {
            Form4.form4.m_styleGalleryItem = this.m_styleGalleryItem;
            IColorRamp colorRamp = this.m_styleGalleryItem.Item as IColorRamp;
            Form4.form4.colorRamp = colorRamp;
            this.Close();
        }


    }
}
